package tdh.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import tdh.entity.po.Bzdm;
import tdh.entity.vo.DepartVo;
import tdh.entity.vo.Result;
import tdh.service.BzdmService;
import tdh.service.DepartService;

import java.util.List;

/**
 * 部门信息控制层
 * @author 曹昊
 * @date 2021/7/12
 */
@Controller
public class AddController {
    //部门信息业务对象
    @Autowired
    DepartService departService;
    @Autowired
    BzdmService bzdmService;

    /**
     * @Author caohao
     * @Description 响应返回全部的部门信息
     * @Date 14:45 2021/7/12
     * @Param []
     * @return tdh.entity.vo.Result
     **/
    @RequestMapping("departs")
    @ResponseBody
    public Result departVos(){
        Result result;
        try {
            result =  Result.success(departService.allDeaprts());
        }catch (RuntimeException e){
            result = Result.error(e.getMessage());
        }
        return result;
    }

    @RequestMapping("bzdms")
    @ResponseBody
    public Result bzdms(){
        Result result;
        try {
            List<Bzdm> bzdms = bzdmService.bzdms();
            result =  Result.success(bzdms);
        }catch (RuntimeException e){
            result = Result.error(e.getMessage());
        }
        return result;
    }


}
